<template>
	
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">我的报名</block>
		</cu-custom>
		<view class="cu-list menu sm-border">
			<view class="cu-item arrow" v-for="(item,index) in list" :key="index" @tap="reviewApply(item.id)">
				<view class="content">
					<text class="text-grey">{{item.wechatNum}}</text>
				</view>
			</view>
			<view class="cu-form-group" @tap="addApply" v-if="list.length !== getFieldDetails.agentCount">
				<text class="text-blue cuIcon-roundaddfill"></text>
				<text class="text-left" style="width: 100%;padding-left: 10px;">
					<text class="text-blue">新增报名</text>
					<text class="text-gray text-sm" style="padding-left: 10px;">(点击"新增报名"，可以代人报名)</text>
				</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {baseUrl} from '@/config/index';
	import {mapState} from 'vuex'
	export default {
		data() {
			return {
				list: [],
				getId: 0
			}
		},
		computed: mapState(['getFieldDetails']),
		onLoad(e) {
			this.getId = e.id
		},
		onShow() {
			this.getList(this.getId)
		},
		methods: {
			getList(id) {
				uni.request({
					url: `${baseUrl}/apply/queryApplyList`,
					data: {activityId: id}
				})
				.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
					var [error, res]  = data;
					if(res.data.recode !== '100') {
						uni.showToast({
							icon: 'none',
							title: error,
						});
						return
					}
					this.list = res.data.data.applyList
				})
			},
			addApply() {
				uni.navigateTo({
					url: `/pages/main/enroll/info?type=edit&id=`,
				});
			},
			reviewApply(e) {
				uni.navigateTo({
					url: `/pages/main/enroll/info?type=edit&id=${e}`,
				});
			}
		}
	}
</script>

<style>
</style>
